# 获取教程、习题、案例，共同学习、讨论、打卡
# 请关注：Crossin的编程教室
# 如果运行代码遇到问题，可加群讨论 - QQ群：155816967
# 如用代码进行二创并发布，请在明显处注明来源：Crossin的编程教室，否则将可能成为我下期视频素材[狗头][冷笑]

import random

kicker = ['玩家', '电脑']
action = ['射门', '扑救']
score = [0, 0]
chance = [5, 5]

def kick():
    for i in range(2):
        you = int(input(f'{kicker[i]}罚球，请玩家选择{action[i]}方向 (1)左 (2)中 (3)右：'))
        com = random.randint(1, 3)
        print('电脑选择了', com)
        if you != com:
            print('球进了！')
            score[i] += 1
        else:
            print('球没进')
        print(f'比分 {score[0]} : {score[1]}')

        if chance[i] > 0:
            chance[i] -= 1
            j = 1 - i    # 获取对手的index
            if (score[i] > score[j] + chance[j]) or (
                score[j] > score[i] + chance[i]):
                return True
    return False
n = 0
while n < 5 or score[0] == score[1]:
    n += 1
    print(f'======== 第{n}轮 ========')
    if kick():
        break

if score[0] > score[1]:
    print('你赢啦！')
else:
    print('你输了')
